<?php
namespace lib;
class Task {
	public static function __callstatic($a, $b) {
	    
		var_dump('no method task');
		var_dump($a);
	}
	
	
	public function updateLocalDeviceId($params) {
	    $localRedis = new LocalRedis();
	    $localRedis->set($params['simId'], $params['id']);
	    $localRedis->close();
	    return json_encode(['statuscode' => 200]);
	}
	
	//下发价格参数
	public static function setChargePriceRule($params) {
	    if(isset($params['simId'])) {
	        unset($params['simId']);
	    }
	    var_dump($params);
	    $params['statuscode'] = 200;
	    $http = new Http();
	    $body = $http->post('setChargeRule', $params);
	    $http->close();
	    return $body;
	}
	
	//开始充电
	public static function startCharge($params) {
		$data = [
		    'deviceId' => $params['deviceId'],
		    'socketNo' => $params['portNo'],
		    'chargeMode' => $params['chargeType'],
		    'chargeTimeV' => $params['quantity'],
			'statuscode' => 200
		];
		
	    $http = new Http();
	    $body = $http->post('startCharge', $data);
	    $http->close();
	    
	    return $body;
	    
	}
	
	//增加充电时间
	public static function addCharge($params) {
		$data = [
		    'deviceId' => $params['deviceId'],
		    'socketNo' => $params['portNo'],
		    'chargeMode' => $params['chargeType'],
		    'chargeTimeV' => $params['quantity'],
    		'statuscode' => 200
		];
		$http = new Http();
		$body = $http->post('addCharge', $data);
		$http->close();
		
		return $body;
	}
	
	//停止充电
	public static function stopCharge($params) {
		var_dump('stopCharge');
		$data = [
		    'deviceId' => $params['deviceId'],
		    'socketNo' => $params['portNo'],
		    'statuscode' => 200
		];
	
		$http = new Http();
		$body = $http->post('stopCharge', $data);
		$http->close();
		return $body;
	}
	
	//线上卡充电
	public static function onlineCardCharge($params) {
	    var_dump('线上卡充电');
	    /* if(!empty($params['cardNo'])) {
	        $params['cardNo'] = strtoupper(dechex($params['cardNo']));
	    } */
	    $data = [
	        'deviceId' => $params['deviceId'],
	        'socketNo' => $params['portNo'],
	        'cardType' => $params['cardType'],
	        'cardID' => $params['cardNo'],
	        'money' => $params['money'],
	        'errCode' => $params['code'],
	        'servRes' => 0,
	        'statuscode' => 400
	    ];
	    
	    var_dump($params);
	    
	    if($params['success'] == true) {
	        $data['servRes'] = 1;
	        $data['statuscode'] = 200;
	    }
	    
	    $http = new Http();
	    $body = $http->post('updateCartUserInfoResult', $data);
	    var_dump($body);
	    $http->close();
	    return $body;
	}

	//修改网关
	public static function updateGateway() {
		var_dump('updateGateway');
		$data = [
		    'deviceId' => $params['deviceId'],
    		'ippart1' => 1,
    		'ippart2' => 1,
    		'ippart3' => 12,
    		'ippart4' => 1,
    		'porth' => 1,
    		'portl' => 1,
		  'statuscode' => 200
		];
		
		$http = new Http();
		$http->post('updateServerIp', $data);
		var_dump($http->body());
		$http->close();
			
		var_dump('end');
	}
	
	//设置代理商
	public static function setAgent($params) {
		$data = [
		    'deviceId' => $params['deviceId'],
		    'agentid' => $params['agentId'],
    		'statuscode' => 200
		];
		
		$http = new Http();
		$body = $http->post('setAgent', $data);
		$http->close();
			
		return $body;
	}
	
	//设备锁
	public static function updateDeviceLock($params) {
		$data = [
		    'deviceId' => $params['deviceId'],
    		'lockType' => $params['lockStatus'],
    		'statuscode' => 200
		];
		
		$http = new Http();
		$body = $http->post('updateDeviceLock', $data);
		$http->close();
		
		return $body;
	}
	
	
	
}









